package com.xiatl.cgi.client;

import com.alibaba.fastjson.JSONObject;
import com.xiatl.cgi.server.cgi.utils.HttpRequestUtil;
import com.xiatl.cgi.server.cgi.utils.SignUtil;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class MainTest {
 // http://10.249.83.204:80/openApi/v1/fileRecognition/getClassifyTask
    public static void main(String[] args) {
        // appKey
        String appKey = "test";
        String appSecret = "ccEZXVG&ctT7qt#Mrh@q";
        String timestamp = new Date().getTime() + "";

        String path = "/openApi/v1/thirdSubmit";

        // 参数
        JSONObject params = new JSONObject();
        params.put("reqData", "");
        params.put("bizType", "ZZJ_GET_COUNTRY_AREA_LIST");
        // 签名
        String sign = SignUtil.sign(params, path, appSecret);
        // 拼装请求url
        String url = "http://127.0.0.1:21217" + path;

        // 设置请求header
        Map<String, String> headers = new HashMap<>();
        headers.put("appKey", appKey);
        headers.put("sign", sign);
        headers.put("timestamp", timestamp);

        // 发起请求
        String result = HttpRequestUtil.post(url, params, headers);
        System.out.println(result);
    }
}
